package blatt3;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.ListIterator;

public class IteratorWrapper<I extends Iterable> implements Iterator{
	
	private I Iterable;

	IteratorWrapper(I h)
	{
		this.Iterable = h;
	}
	
	@Override
	public boolean hasNext() {
		return Iterable.iterator().hasNext();
	}

	@Override
	public Object next() {
		return Iterable.iterator().next();
	}

	@Override
	public void remove() {
		Iterable.iterator().remove();
	}
	
	public void skip(int i) {
		for(int j=0; j<i && Iterable.iterator().hasNext(); j++)
			Iterable.iterator().next();
	}
	
	public static void main(String args[])
	{
		ArrayList<Integer> h = new ArrayList<Integer>();
		h.add(1);
		h.add(2);
		h.add(3);
		h.add(4);
		h.add(5);
		IteratorWrapper<ArrayList<Integer>> IW = new IteratorWrapper<ArrayList<Integer>>(h);
		
		System.out.println("HasNext?: "+IW.hasNext());
		System.out.println("Next: "+IW.next());
		System.out.println("skip one element");
		IW.skip(1);
		System.out.println("Next: "+IW.next());
		System.out.println("Next: "+IW.next());
		System.out.println("Next: "+IW.next());
		System.out.println("HasNext?: "+IW.hasNext());
	}
}
